﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClientRegister
{
    public partial class oldStudentRegisterForm : Form
    {
        public oldStudentRegisterForm()
        {
            InitializeComponent();
        }

        private void oldStudentRegisterForm_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnFind_Click(object sender, EventArgs e)
        {
            StudentDataProvider old = new StudentDataProvider();
            if (chkID.Checked && !chkName.Checked)
            {
                GridInfoStudent.DataSource = old.loadOldInfoID(txtIDorName.Text).Tables[0];
            }
            else if (!chkID.Checked && chkName.Checked)
            {
                GridInfoStudent.DataSource = old.loadOldInfoName(txtIDorName.Text).Tables[0];
            }
            else MessageBox.Show("Chỉ chọn ID hoặc Họ tên");

        }

        private void chkID_CheckedChanged(object sender, EventArgs e)
        {
            if (chkID.Checked) chkName.Checked = false;
        }

        private void chkName_CheckedChanged(object sender, EventArgs e)
        {
            if (chkName.Checked) chkID.Checked = false;
        }

        private void btnRegisClass_Click(object sender, EventArgs e)
        {
            if (GridInfoStudent.SelectedCells.Count > 0)
            {
                OldStudentRegisClassForm oldRe = new OldStudentRegisClassForm();
                oldRe.id = GridInfoStudent.CurrentRow.Cells["ID"].Value.ToString();
                oldRe.name = GridInfoStudent.CurrentRow.Cells["FullName"].Value.ToString();
                oldRe.gender = GridInfoStudent.CurrentRow.Cells["GenderId"].Value.ToString();
                oldRe.birthday = GridInfoStudent.CurrentRow.Cells["Birthday"].Value.ToString();
                oldRe.career = GridInfoStudent.CurrentRow.Cells["Career"].Value.ToString();
                oldRe.email = GridInfoStudent.CurrentRow.Cells["Email"].Value.ToString();
                oldRe.phone = GridInfoStudent.CurrentRow.Cells["Phone"].Value.ToString();
                oldRe.address = GridInfoStudent.CurrentRow.Cells["Address"].Value.ToString();
                oldRe.Show();
            }
        }

        private void btnRegisCourse_Click(object sender, EventArgs e)
        {
            if (GridInfoStudent.SelectedCells.Count > 0)
            {
                OldStudentRegisCourseForm oldRe = new OldStudentRegisCourseForm();
                oldRe.id = GridInfoStudent.CurrentRow.Cells["ID"].Value.ToString();
                oldRe.name = GridInfoStudent.CurrentRow.Cells["FullName"].Value.ToString();
                oldRe.gender = GridInfoStudent.CurrentRow.Cells["GenderId"].Value.ToString();
                oldRe.birthday = GridInfoStudent.CurrentRow.Cells["Birthday"].Value.ToString();
                oldRe.career = GridInfoStudent.CurrentRow.Cells["Career"].Value.ToString();
                oldRe.email = GridInfoStudent.CurrentRow.Cells["Email"].Value.ToString();
                oldRe.phone = GridInfoStudent.CurrentRow.Cells["Phone"].Value.ToString();
                oldRe.address = GridInfoStudent.CurrentRow.Cells["Address"].Value.ToString();
                oldRe.Show();
            }
        }
    }
}
